<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>教师等级信息列表页</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.8.8/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.8.8/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.8.8/themes/color.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.8.8/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.8.8/jquery.easyui.min.js"></script>


</head>
<body>
	<table id="tehGrade_dg" title="教师等级信息列表" class="easyui-datagrid"
		style="width: 1150px; height: 480px"
		url="${param.request.contextPath}/admin/tehGradeList"
		toolbar="#tehGrade_toolbar" pagination="true" rownumbers="true"
		fitColumns="true" singleSelect="true">
		<thead>
			<tr>
				<th field="cb" checkbox="true" align="center"></th>
				<th field="tgId" width="50">等级编号</th>
				<th field="gradeName" width="50">等级名称</th>
			</tr>
		</thead>
	</table>

	<!-- 工具条组件 -->
	<div id="tehGrade_toolbar">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-add" plain="true" onclick="newTehGrade()">新增</a> <a
			href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-edit" plain="true" onclick="editTehGrade()">修改</a> <a
			href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-remove" plain="true" onclick="destroyTehGrade()">删除</a>
	</div>

	<!-- 新增和修改表单  start -->
	<div id="tehGrade_dlg" class="easyui-dialog"
		style="width: 400px; height: 280px; padding: 10px 20px" closed="true"
		buttons="#tehGrade_dlg-buttons">
		<div class="ftitle">教师等级信息管理</div>
		<form id="tehGrade_fm" enctype="multipart/form-data" method="post">
			<div class="fitem">
				<label>等级名称:</label> <input name="gradeName"
					class="easyui-validatebox" required="true">
			</div>
		</form>
	</div>
	<div id="tehGrade_dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok"
			onclick="saveTehGrade()">保存</a> <a href="#" class="easyui-linkbutton"
			iconCls="icon-cancel"
			onclick="javascript:$('#tehGrade_dlg').dialog('close')">取消</a>
	</div>

	<!-- 新增和修改表单 end -->

	<script type="text/javascript">
		// 新增
		function newTehGrade() {
			$('#tehGrade_dlg').dialog('open').dialog('setTitle', '新增教师等级信息');
			$('#tehGrade_fm').form('clear');
			url = '${pageContext.request.contextPath}/tehGrade/add';
		}

		// 修改
		function editTehGrade() {
			$('#tehGrade_fm').form('clear');
			var row = $('#tehGrade_dg').datagrid('getSelected');
			if (row) {
				$('#tehGrade_dlg').dialog('open').dialog('setTitle', '修改教师等级信息');
				$('#tehGrade_fm').form('load', row);
				url = '${pageContext.request.contextPath}/tehGrade/edit?tgId='
						+ row.tgId;
			}
		}

		function saveTehGrade() {
			$('#tehGrade_fm').form('submit', {
				url : url,
				onSubmit : function() {
					return $(this).form('validate');
				},
				success : function(result) {
					var result = eval('(' + result + ')');
					if (!result.success) {
						$.messager.show({
							title : 'Error',
							msg : result.errorMsg
						});
					} else {
						$.messager.show({
							title : 'Info',
							msg : result.errorMsg
						});
					}

					$('#tehGrade_dlg').dialog('close'); // close the dialog
					$('#tehGrade_dg').datagrid('reload'); // reload the user data
				}
			});
		}

		function destroyTehGrade() {
			var row = $('#tehGrade_dg').datagrid('getSelected');
			if (row) {
				$.messager
						.confirm(
								'Confirm',
								'确认删除教师等级信息?',
								function(r) {
									if (r) {
										$
												.post(
														'${pageContext.request.contextPath}/tehGrade/delete',
														{
															tgId : row.tgId
														},
														function(result) {
															if (result.success) {
																$('#tehGrade_dg')
																		.datagrid(
																				'reload'); // reload the user data
															} else {
																$.messager
																		.show({ // show error message
																			title : 'Error',
																			msg : result.errorMsg
																		});
															}
														}, 'json');
									}
								});
			}
		}
	</script>
</body>
</html>